package com.aceitunaproject.client.commands.implementation;

import com.aceitunaproject.client.commands.Parameter;
import com.aceitunaproject.client.commands.implementation.parameters.UnitParameter;
import com.aceitunaproject.clientinterface.AceitunaClientInterface;
import com.aceitunaproject.shared.gamelement.Unit;


/**
 * The order to build an Installation
 * 
 * @author Federico Bergstein
 * 
 */
public class BuildInstallation extends BasicOrder {
	// TODO: this is a pretty crappy implementation of Order, parameters should
	// be stored in an array or list and moved to BasicOrder, good enough for
	// now but must be improved
	/**
	 * The client interface to use to send the order to the server
	 */
	AceitunaClientInterface clientInterface = null;

	public BuildInstallation(AceitunaClientInterface clientInterface) {
		this.clientInterface = clientInterface;
	}


	/**
	 * parameter representing the unit
	 */
	private Parameter<Unit> buildingUnit = new UnitParameter(
			"Unit that builds", " build  ", " in ");

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.client.commands.Order#execute()
	 */
	
	public void execute() {

		clientInterface.buildInstallation(buildingUnit.getValue().getId(),buildingUnit.getValue().getPlayer().getName() + " default installation",buildingUnit.getValue().getPositionX(),buildingUnit.getValue().getPositionY(),"DefaultInstallationType");
		clientInterface.requestMapRefresh();
		executed = true;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.client.commands.Order#getName()
	 */
	
	public String getName() {
		return "Build Installation";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.client.commands.Order#getParameter()
	 */
	
	public Parameter<?> getParameter() {

		return buildingUnit;

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.aceitunaproject.client.commands.Order#moveToNextParameter()
	 */
	
	public boolean moveToNextParameter() {
		
			return false;
		

	}

}
